@echo off
setlocal

REM 主程序开始
echo Initializing git submodules...
git clone https://gitee.com/LauZanMo/glog.git
git clone https://gitee.com/jiajiduan/googletest.git
git clone https://gitee.com/forests/gflags.git
git clone https://gitee.com/switchos/jsoncpp.git

REM 安装各个库
echo Installing glog...
cd glog || exit /b
git checkout v0.5.0
if not exist my_build mkdir my_build
cd my_build || exit /b
cmake .. -DCMAKE_INSTALL_PREFIX=../../win_install/glog || exit /b
cmake --build . --config Debug --target install || exit /b
cd ../..
rd /s /q glog

echo Installing googletest...
cd googletest || exit /b
git checkout v1.14.0
if not exist my_build mkdir my_build
cd my_build || exit /b
cmake .. -DCMAKE_INSTALL_PREFIX=../../win_install/googletest || exit /b
cmake --build . --config Debug --target install || exit /b
cd ../..
rd /s /q googletest

echo Installing gflags...
cd gflags || exit /b
git checkout v2.2.2
if not exist my_build mkdir my_build
cd my_build || exit /b
cmake .. -DCMAKE_INSTALL_PREFIX=../../win_install/gflags || exit /b
cmake --build . --config Debug --target install || exit /b
cd ../..
rd /s /q gflags

echo Installing jsoncpp...
cd jsoncpp || exit /b
git checkout 1.9.5
if not exist my_build mkdir my_build
cd my_build || exit /b
cmake .. -DCMAKE_INSTALL_PREFIX=../../win_install/jsoncpp || exit /b
cmake --build . --config Debug --target install || exit /b
cd ../..
rd /s /q jsoncpp

rd /s /q my_build

echo All libraries installed successfully.
endlocal
